import React,{Component} from 'react';
import {
	View,
	Text,
	Button,
	Platform
} from 'react-native';
//import OpenFile from 'react-native-doc-viewer';

export default class ShowPresent extends Component{

    state = {
        animating: true
    }

	static navigationOptions = ({navigation,navigationOptions})=>{
		return {
			title:navigation.getParam("name"),
		}
	}

	handlePress = () => {
		console.log(111)
        if (Platform.OS === 'ios') {
            OpenFile.openDoc([{
                url: "https://calibre-ebook.com/downloads/demos/demo.docx",
                fileNameOptional: "test filename"
            }], (error, url) => {
                if (error) {

                } else {

                    console.log(url)
                }
            })
        } else {
            //Android

            OpenFile.openDoc([{
                url: "https://www.huf-haus.com/fileadmin/Bilder/Header/ART_3/Header_HUF_Haus_ART_3___1_.jpg", // Local "file://" + filepath
                fileName: "sample",
                cache: false,
                fileType: "jpg"
            }], (error, url) => {
                if (error) {

                    console.error(error);
                } else {

                    console.log(url)
                }
            })
        }
    }
	render(){
		const name = this.props.navigation.getParam("name");
		const id = this.props.navigation.getParam("id");
		return <View>
			<Text>{name+id+this.state.animating}</Text>
			<Button
                onPress={()=>this.handlePress()}
                title="打开远程文档"
            />
		</View>
	}
}
